<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="采购项目编号">
              <a-input placeholder="请输入采购项目编号" v-model="queryParam.purchaseProjectCode"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="采购项目名称">
              <a-input placeholder="请输入采购项目名称" v-model="queryParam.purchaseProjectName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="进场状态">
              <j-dict-select-tag
                placeholder="请选择进场状态"
                v-model="queryParam.status"
                dictCode="gc_project_entry_status"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a-button @click="handleAdd" type="primary" icon="plus" style="margin-left: 8px">新增</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->  
    <!-- table区域-begin -->
    <div>  
      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>
        <span slot="action" slot-scope="text, record">
          <template v-if="record.status == 0  || record.status == 3">
            <a-divider type="vertical" />
            <a @click="handleEdit(record)">编辑</a>

            <a-divider type="vertical" />
            <a-popconfirm title="确定提交吗?" @confirm="() => handleSubmit(record)">
              <a>提交</a>
            </a-popconfirm>
            <a-divider type="vertical" />
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a>删除</a>
            </a-popconfirm>
          </template>
          <a v-else @click="handleDetail(record)">详情</a>
        </span> 

      </a-table>
    </div>

    <ex-purchase-project-modal ref="modalForm" @ok="modalFormOk"></ex-purchase-project-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import ExPurchaseProjectModal from './modules/ExPurchaseProjectModal'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import { httpAction, getAction } from '@/api/manage'

  export default {
    name: 'ExPurchaseProjectList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      ExPurchaseProjectModal
    },
    data () {
      return {
        description: '采购项目管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'采购项目编号',
            align:"center",
            dataIndex: 'purchaseProjectCode'
          },
          {
            title:'采购项目名称',
            align:"center",
            dataIndex: 'purchaseProjectName'
          },
          {
            title:'采购项目类型',
            align:"center",
            dataIndex: 'tenderProjectType_dictText'
          },
          {
            title:'采购人名称',
            align:"center",
            dataIndex: 'purchaserName'
          },
          {
            title:'采购代理机构名称',
            align:"center",
            dataIndex: 'purchaserAgencyName'
          },
          {
            title:'监督部门名称',
            align:"center",
            dataIndex: 'superviseDeptName'
          },
          {
            title:'审核部门名称',
            align:"center",
            dataIndex: 'approveDeptName'
          },
          {
            title:'项目所在行政区划代码',
            align:"center",
            dataIndex: 'regioncode_dictText'
          },
           {
          title: '进场状态',
          align: 'center',
          dataIndex: 'status_dictText',
        },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/exPurchaseProject/exPurchaseProject/list",
          delete: "/exPurchaseProject/exPurchaseProject/delete",
          deleteBatch: "/exPurchaseProject/exPurchaseProject/deleteBatch",
          exportXlsUrl: "/exPurchaseProject/exPurchaseProject/exportXls",
          importExcelUrl: "exPurchaseProject/exPurchaseProject/importExcel",
          submitAudit: 'exPurchaseProject/exPurchaseProject/submitAudit',
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'purchaseProjectCode',text:'采购项目编号',dictCode:''})
        fieldList.push({type:'string',value:'purchaseProjectName',text:'采购项目名称',dictCode:''})
        fieldList.push({type:'string',value:'investProjectCode',text:'投资项目统一代码',dictCode:''})
        fieldList.push({type:'string',value:'tenderProjectType',text:'采购项目类型',dictCode:'cg_project_type'})
        fieldList.push({type:'string',value:'purchaserName',text:'采购人名称',dictCode:''})
        fieldList.push({type:'string',value:'purchaserCode',text:'采购人代码',dictCode:''})
        fieldList.push({type:'string',value:'purchaserRole',text:'采购人角色',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'programBudget',text:'项目预算',dictCode:''})
        fieldList.push({type:'string',value:'budgetCurrency',text:'预算金额币种',dictCode:''})
        fieldList.push({type:'string',value:'unitBudget',text:'预算金额单位',dictCode:''})
        fieldList.push({type:'string',value:'isProject',text:'是否ppp项目',dictCode:'yn'})
        fieldList.push({type:'string',value:'purchaserMode',text:'采购方式',dictCode:'cg_type'})
        fieldList.push({type:'Text',value:'purchaserContent',text:'采购内容',dictCode:''})
        fieldList.push({type:'string',value:'purchaserOrganizeForm',text:'采购组织形式',dictCode:'cg_org_type'})
        fieldList.push({type:'string',value:'purchaserAgencyName',text:'采购代理机构名称',dictCode:''})
        fieldList.push({type:'string',value:'purchaserAgencyCode',text:'采购代理机构代码',dictCode:''})
        fieldList.push({type:'string',value:'purchaserAgencyRole',text:'采购代理机构角色',dictCode:''})
        fieldList.push({type:'string',value:'purchaserAgencyConnector',text:'采购代理机构联系人',dictCode:''})
        fieldList.push({type:'string',value:'purchaserAgencyInformation',text:'采购代理机构联系电话',dictCode:''})
        fieldList.push({type:'string',value:'purchaseSectionCode',text:'采购项目子包编号',dictCode:''})
        fieldList.push({type:'string',value:'purchaseSectionName',text:'采购项目子包名称',dictCode:''})
        fieldList.push({type:'string',value:'superviseDeptName',text:'监督部门名称',dictCode:''})
        fieldList.push({type:'string',value:'superviseDeptCode',text:'监督部门代码',dictCode:''})
        fieldList.push({type:'string',value:'approveDeptName',text:'审核部门名称',dictCode:''})
        fieldList.push({type:'string',value:'approveDeptCode',text:'审核部门代码',dictCode:''})
        fieldList.push({type:'string',value:'unifiedDealCode',text:'统一交易标识码',dictCode:''})
        fieldList.push({type:'string',value:'platformCode',text:'交易系统标识码',dictCode:''})
        fieldList.push({type:'string',value:'regioncode',text:'项目所在行政区划代码',dictCode:'sys_xz_area'})
        fieldList.push({type:'string',value:'projectaddress',text:'项目地址',dictCode:''})
        fieldList.push({type:'string',value:'industriestype',text:'项目行业分类',dictCode:''})
        fieldList.push({type:'string',value:'projectapprovalrecordno',text:'项目批准备案文号',dictCode:''})
        fieldList.push({type:'string',value:'fundsource',text:'资金来源',dictCode:'cg_capital_source'})
        fieldList.push({type:'string',value:'purchaserconnector',text:'采购项目联系人',dictCode:''})
        fieldList.push({type:'string',value:'purchasercontactinformation',text:'采购项目联系人电话',dictCode:''})
        fieldList.push({type:'string',value:'purchaserconnectormobile',text:'采购项目联系人手机',dictCode:''})
        fieldList.push({type:'string',value:'purchaserconnectorzhiwu',text:'采购项目联系人职务',dictCode:''})
        fieldList.push({type:'string',value:'financeentrustcode',text:'财政委托编号',dictCode:''})
        fieldList.push({type:'string',value:'zhaobiaolbXlCode',text:'项目类别',dictCode:''})
        fieldList.push({type:'string',value:'xiangmumoshi',text:'招标模式',dictCode:''})
        fieldList.push({type:'string',value:'isjcandsy',text:'是否基础设施和公用事业特许经营权',dictCode:'yn'})
        fieldList.push({type:'string',value:'isgjzb',text:'是否包含机电国际招投标',dictCode:'yn'})
        fieldList.push({type:'string',value:'supervisionname',text:'监管办专管员',dictCode:''})
        fieldList.push({type:'string',value:'supervisionnametel',text:'监管办专管员联系电话',dictCode:''})
        fieldList.push({type:'string',value:'econormicname',text:'归口业务处室',dictCode:''})
        fieldList.push({type:'string',value:'zigeshenchatype',text:'资格审查方式',dictCode:''})
        fieldList.push({type:'string',value:'zixingwenhao',text:'自行采购核准文号',dictCode:''})
        this.superFieldList = fieldList
      },
    handleSubmit(row) {
      var that = this
      httpAction(this.url.submitAudit + '?id=' + row.id, row, 'post')
        .then((res) => {
          if (res.success) {
            that.$message.success(res.message)
            that.loadData()
          } else {
            that.$message.warning(res.message)
          }
        })
        .finally(() => {
          that.confirmLoading = false
        })
    },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>